<?php

namespace Syrius\Query;


/**
 * Classe che gestisce le query SHOW
 * @package	Query
 * @author	Domenico Biancardi <domenico.biancardi@gmail.com>
 * @link	http://code.google.com/p/syrius/
 *
 */ abstract class Show {
	/**
	 * chiave che viene usata nello show
	 */
	private $_key;

	/**
	 * valore utilizzato nella funzione
	 */
	private $_value;

	final public function get_key() {
		return $this->_key;
	}

	public function set_key($value) {
		$this->_key = $value;
	}

	final public function get_value() {
		return $this->_value;
	}

	public function set_value($value) {
		$this->_value = $value;
	}

	/**
	 * compone key e value per ottenere la query desiderata
	 */
	public function __toString() {
		$sql = "SHOW " . $this->_key;
		if ($this->_value != "") {
			$sql .= " LIKE '" . $this->_value . "'";
		}
		return $sql;
	}

}

/**
 * Enter description here ...
 * @package	Query
 * @author	Domenico Biancardi <domenico.biancardi@gmail.com>
 * @link	http://code.google.com/p/syrius/
 *
 */
class Show_Charset extends Show {
	public function __construct() {
		$this->set_key("CHARSET");
	}

}

/**
 * Enter description here ...
 * @package	Query
 * @author	Domenico Biancardi <domenico.biancardi@gmail.com>
 * @link	http://code.google.com/p/syrius/
 *
 */
class Show_Collation extends Show {
	public function __construct() {
		$this->set_key("COLLATION");
	}

}

/**
 * Enter description here ...
 * @package	Query
 * @author	Domenico Biancardi <domenico.biancardi@gmail.com>
 * @link	http://code.google.com/p/syrius/
 *
 */
class Show_Engine extends Show {
	public function __construct() {
		$this->set_key("ENGINES");
	}

}

/**
 * Enter description here ...
 * @package	Query
 * @author	Domenico Biancardi <domenico.biancardi@gmail.com>
 * @link	http://code.google.com/p/syrius/
 *
 */
class Show_Table extends Show {
	/**
	 * Imposta la tabella che si vuole cercare
	 */
	public function setTable($table) {
		$this->set_value($table);
	}

	public function __construct() {
		$this->set_key("TABLES");
	}

}

/**
 * Enter description here ...
 * @package	Query
 * @author	Domenico Biancardi <domenico.biancardi@gmail.com>
 * @link	http://code.google.com/p/syrius/
 *
 */
class Show_Columns extends Show {
	/**
	 * Imposta la tabella che si vuole cercare
	 */
	public function setTable($table) {
		$this->set_value($table);
	}

	public function __construct() {
		$this->set_key("COLUMNS");
	}

	/**
	 * compone key e value per ottenere la query desiderata
	 */
	public function __toString() {
		$sql = "SHOW " . $this->get_key();
		if ($this->get_value() != "") {
			$sql .= " FROM  " . $this->get_value();
		}
		return $sql;
	}

}

/**
 * Enter description here ...
 * @package	Query
 * @author	Domenico Biancardi <domenico.biancardi@gmail.com>
 * @link	http://code.google.com/p/syrius/
 *
 */
class Show_Autocommit {
	public function __toString() {
		return "SELECT @@autocommit";
	}

}

/**
 * Enter description here ...
 * @package	Query
 * @author	Domenico Biancardi <domenico.biancardi@gmail.com>
 * @link	http://code.google.com/p/syrius/
 *
 */
class Show_Keys extends Show {
	/**
	 * Imposta la tabella che si vuole cercare
	 */
	public function setTable($table) {
		$this->set_value($table);
	}

	public function __construct() {
		$this->set_key("KEYS");
	}

	/**
	 * compone key e value per ottenere la query desiderata
	 */
	public function __toString() {
		$sql = "SHOW " . $this->get_key();
		if ($this->get_value() != "") {
			$sql .= " FROM  " . $this->get_value();
		}
		return $sql;
	}

}

?>
